﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tunnel.Tools
{
    public static class LogDB
    {
        public static bool CommandLog(string deviceType, string deviceID, string detail)
        {
            SqlDBHelper sdh = new SqlDBHelper();

            string logid = new Global().CommandID;
            string userid = Global.UserID;
            string datetime = DateTime.Now.ToString();

            string insertIntoLog = "INSERT INTO [H_Log] ( [LogID],[UserID],[DeviceType],[DeviceID],[Detail],[UpdateTime] ) VALUES('" + logid + "', '" + userid + "', '" + deviceType + "', '" + deviceID + "', '" + detail + "', '" + datetime + "')";

            try
            {
                int i = sdh.ExecuteCommand(insertIntoLog);
                if (i == 0)
                {
                    return false;
                }
                return true;
            }
            catch
            {
                return false;
            }
        }
    }
}
